package PolladminFunc;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import bean.Poll;

import poll.*;

public class DefinePoll extends HttpServlet {

	private static final long serialVersionUID = 6105195244568374433L;

	public DefinePoll(){
		super();
	}
	@Override
	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doPost(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		HttpSession session=request.getSession(true);
		String name=request.getParameter("name");
		String latitude=request.getParameter("latitude");
		String longitude=request.getParameter("longitude");
		String description=request.getParameter("description");
		String creator=request.getParameter("creator");
		
		Poll poll=new Poll();
		poll.setName(name);
		poll.setLatitude(latitude);
		poll.setLongitude(longitude);
		poll.setDescription(description);
		
		PollDAO pd=new PollDAO();
		pd.add(poll);
		response.sendRedirect("poll.jsp");
	}

	@Override
	public void destroy() {
		// TODO Auto-generated method stub
		super.destroy();
	}

	@Override
	public void init() throws ServletException {
		// TODO Auto-generated method stub
		super.init();
	}

	
}
